package com.solr.self.search;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrQuery.ORDER;

/**
 * 
 * <solr查询参数封装类>
 * <功能详细描述>
 * 
 * @author  huanglizhi
 * @version  [版本号, 2012-7-10]
 * @see  [相关类/方法]
 * @since  [产品/模块版本]
 */
public class SolrSearchBasePO implements Serializable
{
    private static final long serialVersionUID = 3372877034586052209L;

    /** 查询参数 */
    private HashMap<String, Object> paramMap = new HashMap<String, Object>();

    /** 需要查询的字段 ，solr默认为*查询所有*/
    private String fl;
    
    /** solr 字段排序，排序是有先后顺序的，所以使用LinkedHashMap */
    private Map<String, SolrQuery.ORDER> orderMap = new LinkedHashMap<String, SolrQuery.ORDER>();
    
    /** 关键字是否高亮， 默认为false不高亮显示*/
    boolean is_hl = false;
    
    /** 高亮字段，默认不高亮*/
    private String hl_fl;
    
    /** 是否启用分组 */
    boolean is_facet = false;
    
    /** 查询参数 */
    private List<String> facetParamList = new ArrayList<String>();
    
    /** 解析后的查询条件 */
    private String paramStr;
    
	/** 起始记录数 */
    int offset = 0;

    /** 截止记录数 */
    int limit = 10;
    
	/** 设置参数 */
    public void setParam(String key, Object obj)
    {
        this.paramMap.put(key, obj);
    }

    /** 获取参数 */
    public Object getParam(String key)
    {
        return this.paramMap.get(key);
    }

    public int getOffset()
    {
        return offset;
    }

    public void setOffset(int offset)
    {
        this.offset = offset;
    }

    public int getLimit()
    {
        return limit;
    }

    public void setLimit(int limit)
    {
        this.limit = limit;
    }

	public HashMap<String, Object> getParamMap()
    {
        return paramMap;
    }

    public void setParamMap(HashMap<String, Object> paramMap)
    {
        this.paramMap = paramMap;
    }

    public String getParamStr()
    {
        return paramStr;
    }

    public void setParamStr(String paramStr)
    {
        this.paramStr = paramStr;
    }
    
    public String getFl() {
		return fl;
	}

	public void setFl(String fl) {
		this.fl = fl;
	}

	public boolean getIs_hl() {
		return is_hl;
	}

	public void setIs_hl(boolean is_hl) {
		this.is_hl = is_hl;
	}

	public String getHl_fl() {
		return hl_fl;
	}

	public void setHl_fl(String hl_fl) {
		this.hl_fl = hl_fl;
	}
	
	/** 设置排序参数 */
    public void setOrderParam(String key, SolrQuery.ORDER order){
    	this.orderMap.put(key, order);
    } 
    
    /** 获取排序参数 */
    public SolrQuery.ORDER getOrderParam(String key)
    {
        return this.orderMap.get(key);
    }

    public Map<String, ORDER> getOrderMap() {
		return orderMap;
	}

	public void setOrderMap(LinkedHashMap<String, SolrQuery.ORDER> orderMap) {
		this.orderMap = orderMap;
	}
	
	 /** 获取是否分组 */
    public boolean getIs_facet() {
		return is_facet;
	}
    
    /** 设置分组*/
	public void setIs_facet(boolean is_facet) {
		this.is_facet = is_facet;
	}
	
	/** 设置分组字段 */
	public void setFacetParamStr(String facetParamStr) {
		this.facetParamList.add(facetParamStr);
	}
	
	/** 获取所有分组字段 */
	public List<String> getFacetParamList()
    {
        return facetParamList;
    }

	/** 设置分组字段 */
    public void setFacetParamList(List<String> facetParamList)
    {
        this.facetParamList = facetParamList;
    }

}
